package org.example.rabbitmq.provider.notify;

import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 动态创建Queue通知，通知所有消费端实例监听此队列
 */
@Component
public class QueueCreatedNotifier {
    public static final String NOTIFY_EXCHANGE_NAME = "data-queue-notify-exchange";
    @Autowired
    AmqpTemplate amqpTemplate;

    public void broadcast(String queueName) {
        amqpTemplate.convertAndSend(NOTIFY_EXCHANGE_NAME, "", queueName);
    }
}